#!/usr/bin/perl

require "./mailadmin-lib.pl";
&ReadParse();

#&header($text{'index_title'}, "", "index", 0, 1);
my ($action, $servname, %st_serv, $err_msg);

&get_service_status(\%st_serv);


$action = $in{'serv_act'};
$servname = $in{'servradio'};

if ($action eq 'start')
{
    if ($st_serv{$servname} eq $text{'st_run'})
    {
	$err_msg = &text('msg_serv_already_act', $text{'st_run'});
	goto ERROR_OUT;
    }
}

if ($action eq 'stop')
{
    if ($st_serv{$servname} eq $text{'st_stop'})
    {
	$err_msg = &text('msg_serv_already_act', $text{'st_run'});
	goto ERROR_OUT;
    }
}

if ($servname eq 'mailserv')
{
    if ($action eq "stop")
    {
	&serv_act("popserv", "stop");
	&serv_act("smtpserv", "stop");
	&serv_act("mailserv", "stop");
    } else {
	&serv_act("popserv", "stop");
	&serv_act("smtpserv", "stop");
	&serv_act("mailserv", "restart");
	&serv_act("smtpserv", "start");
	&serv_act("popserv", "start");
    }
} else {

    &serv_act($servname, $action);

}

&redirect("");

#print "succ!";



 ERROR_OUT:
&error_setup($text{'err_title_serv_act'});
&error($err_msg);



#&footer("", $text{"index"});

# ERROR_OUT:

